home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Application.h
-
- Contains: TApplication interface
-
- This module derived from the Apple Shared Library Manager
- sample source code supplied with ASLM 1.1 (note that ASLM
- is NOT required for, or used in, this project).
-
- Developed by:
-
- Paul G Smith (commstalk hq & Full Moon Software, Inc)
-
- you can leave messages at (UK): 0727 844232; (US): 408 253 7199
- BUT I prefer to be contacted by e-mail
- AppleLink: SMITH.PG
- Internet: SMITH.PG@applelink.apple.com
-
- "SimpliFace" Sample code to accompany develop article
- on techniques for embedding scripts in applications.
-
- */
-
- #ifndef __APPLICATION__
- #define __APPLICATION__
-
- #ifndef __DESK__
- #include <Desk.h>
- #endif
-
- #ifndef __OSUTILS__
- #include <OSUtils.h>
- #endif
-
- #ifndef __APPLEEVENTS__
- #include <AppleEvents.h>
- #endif
-
- #ifndef __SCRIPTOBJECTS__
- #include "ScriptableObjects.h"
- #endif
-
-
- /* this is a type declartion for the qd global so we can access its fields */
- /* given a pointer to qd. For some reason quickdraw doesn't define this type. */
- struct qdRec {
- char privates[76];
- long randSeed;
- BitMap screenBits;
- Cursor arrow;
- Pattern dkGray;
- Pattern ltGray;
- Pattern gray;
- Pattern black;
- Pattern white;
- GrafPtr thePort;
- };
-
- /*
- TApplication:
-
- This is our class which implements a basic Macintosh style program,
- including a MultiFinder-aware event loop.
- */
-
- class TApplication : public TScriptableObject
- {
- public:
- // Our constructor & destructor
- TApplication(Ptr qdPtr);
- TApplication();
- virtual ~TApplication();
-
- // Call this routine to start event loop running
- virtual void EventLoop();
-
- // Call this routine to run event loop once
- virtual void InEventLoop();
-
- protected:
- // Returns total stack space required in bytes.
- // Returns 0 by default, which tells the initialization code
- // to use the default stack size.
- virtual long StackNeeded();
- // Returns total heap space required in bytes.
- // Returns 0 by default, which tells the initialization code
- // to use whatever heap size is given.
- virtual long HeapNeeded();
-
- static void AlertUser(short errResID, short errCode);
- static void BigBadError(short errResID, short errCode);
-
- // Loop control methods you may need to override
- virtual void SetUp(); // Run before event loop starts
- virtual void CleanUp(); // run at end of loop
- virtual void ExitLoop(); // to end loop, call this routine
- virtual void DoIdle(); // idle time handler (blink caret, background tasks)
- virtual void AdjustMenus(); // menu updater routine
-
- virtual Boolean HandleEvent (EventRecord& theEvent, Boolean& pass);
- // returns true if event was handled
-
- // event handlers you shouldn't need to override in a typical application
- virtual void DoKeyDown(); // also called for autokey events
- virtual void DoActivateEvt(); // handles setup, and calls DoActivate (below)
- virtual void DoUpdateEvt(); // handles setup, and calls DoUpdate (below)
- virtual void DoHighLevelEvent(); // handles Apple Events
- virtual void DoOSEvent(); // Calls DoSuspend, DoResume and DoIdle as apropos
- virtual void DoMouseDown(); // Calls DoContent, DoGrow, DoZoom, etc
- virtual void DoMouseInSysWindow();
- virtual void DoDrag();
- virtual void DoGoAway(); // handles setup, calls TDocument::DoClose
-
- // called by EventLoop and its handlers:
- virtual void AdjustCursor(); // cursor adjust routine, should setup mouseRgn
- virtual void DoMenuCommand(short menuID, short menuItem);
- // called by OSEvent (just calls DoActivate by default, so no clip conversion
- // is done). If you want to convert clipboard, override these routines
- virtual void DoSuspend(Boolean doClipConvert);
- virtual void DoResume(Boolean doClipConvert);
-
- // If you have an app that needs to know about these, override them
- virtual void DoMouseUp();
- virtual void DoDiskEvt();
-
- // Utility routines you need to provide to do MultiFinder stuff
- virtual unsigned long SleepVal(); // how long to sleep in WaitNextEvent
-
- private:
- virtual void InitApplication(Ptr qdPtr);
-
- protected:
- // useful variables
- Boolean fDone; // set to true when we are ready to quit
- EventRecord fTheEvent; // our event record
- WindowPtr fWhichWindow; // currently active window
- Boolean fInBackground; // true if our app is suspended
- Boolean fWantFrontClicks; // true if we want front clicks
- RgnHandle fMouseRgn; // mouse moved region (set it in your DoIdle)
- qdRec* fqd; // pointer to our qd globals
- };
-
- #endif
-